package com.itheima.mp.controller;


import com.itheima.mp.domain.vo.AddressVO;
import com.itheima.mp.service.IAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 王岩尘
 * @since 2024-06-22
 */
@RestController
@RequestMapping("/address")
@Api(tags = "收货地址管理")
public class AddressController {
    @Autowired
    private IAddressService addressService;

    /**
     * 根据用户id查询地址
     *
     * @param userId 用户id
     * @return List<AddressVO>
     */
    @GetMapping("/{userId}")
    @ApiOperation("根据用户id查询地址")
    public List<AddressVO> getAddressById(@ApiParam("用户id") @PathVariable Long userId) {
        return addressService.getAddressByUserId(userId);
    }

}
